import Ships.Miner
import coords

# **
# *  'Depositing' is a state class utilised when the Miners cargo hold is full.
# *
# * PUBLIC FEATURES:
# *    // Constructors
# *    def __init__(self)
# *
# *    // Methods
# *    def Enter(self, foot)
# *    def Execute(self, foot)
# *    def Exit(self, foot)
# *    
# *
# *    COLLABORATORS:
# *    Ships.Miner
# *
# * MODIFIED:
# * @version 1.1, 2007-05-24
# * @author Julian Andreou 5422329
# * @author Gavan Hunter 5422264
# * @author  Simon Iskra 5422361
# * @author  Joel Schmidt 2660660
# */

class Depositing():
    def __init__(self): 
        self.stateString = "Depositing"
    #  if has no home path
    #  ask for a path back to home planet
    #  else contine home
    #  Once home deposit mineral, cargo = 0, planet minerals + cargo
    #  
    #  TRANSITIONS
    #  If threatened then flee
    #  If deposited then mining

    def Enter(self, ship):
        ship.path = ship.map.findPath(ship.getGridCoords(), ship.homeBase)
        ship.pathCount = 0
    
    def Execute(self, ship): 
        if ship.pathCount<len(ship.path.nodes):
            ship.position = coords.gridToScreen([ship.path.nodes[ship.pathCount].location.x,ship.path.nodes[ship.pathCount].location.y])
        else:
            print "unloading"
            ship.map.depositMinerals(ship.minerals)
            ship.minerals = 0            
        
           
        ship.pathCount+=1
    
    def Exit(self, ship):
        pass
    

